//package src.main;
//import com.lowagie.text.pdf.hyphenation.TernaryTree.Iterator;
//import java.util.Iterator;
//import edu.stanford.smi.protege.exception.OntologyLoadException;
//import java.rmi.Naming;
//import edu.stanford.smi.protege.server.RemoteServer;
//import edu.stanford.smi.protege.server.RemoteServerProject;
//import edu.stanford.smi.protege.server.RemoteSession;
//import edu.stanford.smi.protege.server.Server;
//import edu.stanford.smi.protege.util.SystemUtilities;
//import edu.stanford.smi.protegex.owl.ProtegeOWL;
//import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
//import edu.stanford.smi.protegex.owl.model.RDFSClass;
//import edu.stanford.smi.protege.server.RemoteClientProject;
//import javaclient2.PlayerClient;
//import javaclient3.PlayerClient;
//import edu.stanford.smi.protege.model.KnowledgeBase;
//import edu.stanford.smi.protege.model.Project;
//import edu.stanford.smi.protege.server.RemoteProjectManager;
//import edu.stanford.smi.protegex.owl.model.OWLModel;
//import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
//import edu.stanford.smi.protegex.owl.model.RDFSClass;
//import javaclient3.*;
//import javaclient3.structures.*;
//import javaclient3.structures.fiducial.PlayerFiducialData;
//import javaclient3.structures.fiducial.PlayerFiducialItem;

import java.util.ArrayList;

import robot.Robot;
import robot.MaterialObject;
import ontology.Ontology;

public class awarerobot {

	public static void main(String[] args) {
		int i = 0;
		
		Robot robot = new Robot();
		Ontology ontology = new Ontology("localhost", "Agent1", "Agent1", "Awarerobot");
		robot.setPathpoints(ontology.getPathpoints("Plane_1"));
		robot.start();
		//robot.readAll();
		//System.out.println(robot.getPos().getX() + ", " + robot.getPos().getY());
		//robot.getPos().setSpeed(0.1, 0.1);
		
		while(true) {
			
			ArrayList<MaterialObject> detectedObjects = robot.detectObjects();
			//System.out.println("Fiducial detected: " + detectedObjects.length);

			for (int ifid = 0; ifid < detectedObjects.size(); ifid++) {  // i indexes each element successively.
				//System.out.println("Fiducial: " + detectedObjects.get(ifid).getId() + " at pos " + detectedObjects.get(ifid).getAbsPose().getPx() + ", " + detectedObjects.get(ifid).getAbsPose().getPy());
				ontology.actualizeObject(detectedObjects.get(ifid));
			}
			//robot.getPos().
			//if (plni.isDataReady ()) {
			//	PlayerPlannerData ppd = plni.getData ();
			//	System.err.println (ppd.getWaypoints_count ());
			//}
			
			try { Thread.sleep (100); } catch (Exception e) { e.printStackTrace(); }
			
			//i++;
			//if (i == 500)	// modify -1 to a number if you wish to terminate
						// after X iterations
			//	break;
		}

		/*OWLModel model = connectProtege();

		OWLNamedClass objectClass = model.getOWLNamedClass("Object");
		OWLNamedClass ExagonClass = model.createOWLNamedSubclass("Exagon", objectClass);
		*/
		//owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
		//OWLNamedClass objectClass = owlModel.getOWLNamedClass("Object");
		//OWLNamedClass ExagonClass = owlModel.createOWLNamedSubclass("Exagon", objectClass);
		//System.out.println("Class URI: " + worldClass.getURI());
		
		//printClassTree(owlModel.getOWLThingClass(), "-");
		//ProtegeOWL.
		//owlModel.;

		//System.out.println("done");
		//while(true);
	}
	
/*	private static void printClassTree(RDFSClass cls, String indentation) {
		//if (cls.getURI().startsWith("http://www.owl-ontologies.com/Ontology1306150849.owl")) {
		//System.out.println(indentation + cls.getName().startsWith("http://www.owl-ontologies.com/Ontology1306150849.owl"));
			System.out.println(indentation + cls.getName());
		//}
		for (Iterator it = cls.getSubclasses(false).iterator(); it.hasNext();) {
			RDFSClass subclass = (RDFSClass) it.next();
			printClassTree(subclass, indentation + "	");
		}
	}
*/
}
